package com.caregiver.watch.business.user.controller;

import com.caregiver.watch.business.user.model.dto.AddContactDeviceParam;
import com.caregiver.watch.business.user.model.dto.EditContactDeviceParam;
import com.caregiver.watch.business.user.model.vo.ContactDeviceDetailVo;
import com.caregiver.watch.business.user.model.vo.UserDeviceVo;
import com.caregiver.watch.business.user.service.UserDeviceService;
import com.caregiver.watch.common.domain.R;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Description: 用户设备管理
 * @Author 疆戟
 * @Date 2025/8/24 21:07
 * @Version 1.0
 */
@Tag(name  = "UserDeviceController", description = "用户设备管理")
@RestController
@RequestMapping("user/device")
public class UserDeviceController {


    @Autowired
    private UserDeviceService userDeviceService;


    @Operation(summary = "查询用户设备列表", description = "查询用户设备列表")
    @GetMapping("queryUserDeviceList")
    public R<List<UserDeviceVo>> queryUserDeviceList() {
        return R.ok(userDeviceService.queryUserDeviceList());
    }

    // 查询设备详情
    @Operation(summary = "查询亲友设备详情", description = "查询设备详情")
    @GetMapping("queryContactDeviceDetail")
    public R<ContactDeviceDetailVo> queryContactDeviceDetail(@RequestParam("deviceId") Long deviceId) {
        return R.ok(userDeviceService.queryContactDeviceDetail(deviceId));
    }

    /**
     * 添加亲友设备
     */
    @Operation(summary = "添加亲友设备", description = "添加亲友设备")
    @PostMapping("addContactDevice")
    public R<Boolean> addContactDevice(@RequestBody AddContactDeviceParam param) {
        return R.ok(userDeviceService.addContactDevice(param));
    }

    // 编辑亲友设备
    @Operation(summary = "编辑亲友设备", description = "编辑亲友设备")
    @PostMapping("editContactDevice")
    public R<Boolean> editContactDevice(@RequestBody EditContactDeviceParam param) {
        return R.ok(userDeviceService.editContactDevice(param));
    }

    @Operation(summary = "删除亲友设备", description = "删除亲友设备")
    @DeleteMapping("deleteContactDevice")
    public R<Boolean> deleteContactDevice(@RequestParam("deviceId") Long deviceId) {
        return  R.ok(userDeviceService.deleteContactDevice(deviceId));
    }
}
